<!--  -->
<template>
  <div>
    添加联络信息

    <el-form
    ref="ruleFormRef"
    label-width="auto"
    class="ruleForm"
  >
    <el-form-item label="机构名称">
      <el-input  placeholder="请输入机构名称"  />
    </el-form-item>
    <el-form-item label="经度">
      <el-input v-model="state.lng"  placeholder="请输入经度"  />
    </el-form-item>
    <el-form-item label="纬度">
      <el-input v-model="state.lat"   placeholder="请输入纬度"  />
      <el-button type="primary" @click="getLngLat">获取经纬度</el-button>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" >登录</el-button>
    </el-form-item>
  </el-form>

  <Map v-if="isShowMap" @sendlnglat="sendlnglatFn"></Map>
  </div>
</template>

<script lang='ts' setup>
import Map from '../components/Map.vue'
import { reactive,toRefs,ref,onMounted} from 'vue'

const isShowMap=ref(false);

const state=reactive({
    lng:"",
    lat:""
   
})

const sendlnglatFn=(val:any)=>{

    console.log("接收到的数据",val);

    if(val.length>0){
        state.lng=val[0];
        state.lat=val[1];
    }

    isShowMap.value=false;
    

}

const getLngLat=()=>{
    isShowMap.value=true;
}
</script>
<style>
.amap-sug-result{
    z-index: 999999;
}
</style>